package com.lanqiao.companymanage.controller;

import com.lanqiao.companymanage.entity.User;
import com.lanqiao.companymanage.service.PersonalSalaryService;
import com.lanqiao.companymanage.utils.Constant;
import com.lanqiao.companymanage.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @author 何小棍
 * 个人工资查询
 */
@RestController
@RequestMapping("/personalSalary")
@Api(tags = "个人工资")
public class PersonalSalaryController {

    @Autowired
    PersonalSalaryService personalSalaryService;

    /**
     * 登录后查询个人工资
     * @param session
     * @return
     */
    @GetMapping("/getPersonalSalary")
    @ApiOperation(value = "登录后查询个人工资",notes = "不需要任何参数")
    public Result getPersonalSalary(HttpSession session){
        Integer id = (Integer) session.getAttribute(Constant.USER_SESSION);
        User user = personalSalaryService.getPersonalSalary(id);
        return Result.success(user);
    }

}
